package com.qf.swagger2204.utils;

import com.qf.swagger2204.entity.User;

/**
 * 建造者模式案例
 * 可以通过这个UserBuilder对象创造一个user对象
 * 要求：实现链接调用编码风格
 */
public class UserBuilder {
    private User user;
    public UserBuilder(){
        this.user = new User();
    }
    public UserBuilder id(Integer id){
        this.user.setId(id);
        return this;
    }
    public UserBuilder name(String name){
        this.user.setName(name);
        return this;
    }
    public User build(){
        return user;
    }

    public static void main(String[] args) {
        UserBuilder userBuilder = new UserBuilder();
        User user = userBuilder.id(100).name("zs").build();
        System.out.println(user);
    }
}
